package com.fanco.learn_datastruct_leetcode.juc;

import java.util.concurrent.locks.LockSupport;

/**
 * @author qiaowang 2021/11/16
 * 描述
 */
public class LockSupportDemo {
    public static void main(String[] args) {
        Thread a = new Thread(() -> {
            System.out.println(Thread.currentThread().getName() + " 线程阻塞");

            LockSupport.park();

            System.out.println(Thread.currentThread().getName() + " 线程被唤醒");
        }, "A");
        a.start();


        Thread b = new Thread(() -> {
            System.out.println(Thread.currentThread().getName() + " 线程启动");
            LockSupport.unpark(a);
        }, "B");
        b.start();
    }
}
